﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NcfDB
{
    public partial class CreateDBForm : Form
    {
        private bool isRename = false;
        public CreateDBForm()
        {
            InitializeComponent();
        }
        public CreateDBForm(bool isRename)
        {
            InitializeComponent();
            this.isRename = isRename;
        }
        private void ok_Click(object sender, EventArgs e)
        {
            if(this.isRename == false)
            {
                String dbName = this.new_db_name.Text;
                CoreDBSystem.createDB(dbName);
                Program.core.save();
                this.Close();
            }
            else
            {
                MainForm mf = (MainForm)this.Owner;
                mf.rename = this.new_db_name.Text;
                this.Close();
            }
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void new_db_name_TextChanged(object sender, EventArgs e)
        {
            if (this.new_db_name.Text != null)
                this.ok.Enabled = true;
            else
                this.ok.Enabled = false;
        }

        private void CreateDBForm_Load(object sender, EventArgs e)
        {
            if(this.isRename == true)
            {
                this.Text = "重命名";
                this.label1.Text = "输入新名称";
            }
        }

    }
}
